package cn.snorlaxzjt.LBSserver.mapper;

import cn.snorlaxzjt.LBSserver.po.entity.Comment;
import cn.snorlaxzjt.LBSserver.po.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper

@Repository
public interface UserMapper extends BaseMapper<User> {


    /**
     * 查询邮箱是否存在，若存在，不允许注册
     * 注解@Param(value) 若value与可变参数相同，注解可省略
     * 注解@Results  列名和字段名相同，注解可省略
     * @param email
     * @return
     */
    @Select(value = "select email from user u where u.email=#{email}")
    String findUserByEmail(@Param("email") String email);


    @Select(value = "select username,avatar,email from user where id=${id}")
    User findUserById(Integer id);

    /**
     * 注册  插入一条user记录
     * @param user
     * @return
     */
    /*
    @Insert("insert into user values(#{username},#{email},#{password})")
    //加入该注解可以保存对象后，查看对象插入id
    @Options(useGeneratedKeys = true,keyProperty = "recordId",keyColumn = "recordId")
    void regist(UserInfo user);*/

}
